package com.ms.demo;

import com.ms.demo.entity.Dept;
import com.ms.demo.mapper.DeptDataMapper;
import com.ms.demo.utils.SqlSessionUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

/**
 * @description: 一对多查询
 * @author: ms
 * @create: 2022-08-20 18:03
 */
public class MybatisMysqlTest4 {

    /**
     * @Description: getEmpAndDeptById3  一对多查询
     * @Date: 2022/8/20 17:44
     */
    @Test
    public void getEmpAndDeptById3(){
        SqlSession sqlSession = SqlSessionUtils.getSqlSession();
        DeptDataMapper mapper = sqlSession.getMapper(DeptDataMapper.class);
        Dept dept = mapper.getDeptAndEmpById("1");
        System.out.println(dept);
        dept.getEmpList().forEach(System.out::println);
    }
}